package hadoop.mr01;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class partiton_reducer extends Reducer<Text, LongWritable, Text, LongWritable> {
    /*
     * 海鲜,<1>
     * 烧烤,<1,1,1>
     * */
    private static LongWritable num = new LongWritable();
    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        int count = 0;
//        <1,1,1>
        for(LongWritable n:values){
            count+=n.get();
        }
//        3
        num.set(count);
//        烧烤,3
        context.write(key,num);
    }
}
